<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model common\models\Banner */
/* @var $form yii\widgets\ActiveForm */
$this->registerCssFile('/uploadImg/css/fileinput.css');
$this->registerCssFile('/uploadImg/css/default.css');
$this->registerJsfile('/uploadImg/js/fileinput.js', [
    'depends' => 'yii\web\YiiAsset',
    'position' => \yii\web\View::POS_END
]);

?>

<div class="banner-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'logo')->fileInput()?>

    <?= $form->field($model, 'url')->textInput(['maxlength' => true])?>

    <?= $form->field($model, 'type')->textInput()?>

    <?= $form->field($model, 'order')->textInput()?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary'])?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
<?php
$logo = $model->logo != '' ? "'{$model->logo}'" : '';
$js = "$('#banner-logo').fileinput({'showUpload':false,'initialPreview':[{$logo}],'msgSelected':'{n}个文件已上传','allowedFileExtensions' : ['jpg', 'png','gif','jpeg'],});
	  
	   ";
$this->registerJs($js);
?>